package com.ilearn.actor;

public abstract class AbstractActor implements Actor {

	private ActorContext context;

	/**
	 * 初始化
	 * @throws Exception
	 */
	public void preStart() throws Exception {
		
	}

	/**
	 * 接受消息对象
	 * @param msg
	 * @throws Exception
	 */
	public abstract void receive(Object msg) throws Exception;

	/**
	 * 结束回收
	 * @throws Exception
	 */
	public void postStop() throws Exception {
		
	}

	/**
	 * 增加 ActorContext 引用
	 * @param context ActorContext
	 */
	public void setContext(ActorContext context) {
		this.context = context;
	}

	/**
	 * 获取 ActorContext
	 * @return ActorContext
	 */
	public ActorContext context() {
		return this.context;
	}

}
